<style lang="less" scoped>
.panel {
  margin-bottom: 10px;
  &-title {
    display: flex;
    padding: 10px;
    border-bottom: 0.1px solid #eaeaea;
    background: white;

    &__label {
      flex: 1;
      font-size: 16px;
      align-items: center;
    }
  }
  &-content {
    margin-bottom: 10px;
    background: white;
    display: flex;

    &__dec {
      flex: 1;
    }
    &__arrow {
      display: flex;
      align-items: center;
    }
    &__item {
      display: flex;
      padding: 10px 10px 0 10px;
      font-size: 14px;
      &-label {
        color: #666;
      }
      &-value {
        flex: 1;
        padding-left: 15px;
        color: #333;
      }
    }
  }
}
</style>

<template>
  <!-- list -->
  <div class="panel">
    <div class="info" v-if="items&&items.length==0">暂无数据</div>

    <template v-if="items" v-for="(item, index) in items" wx:key="unique">
      <!-- title -->
      <!-- <div class="panel-title" :key="'title'+index">
        <div class="panel-title__label" v-html="item.LicensDocName"></div>
        <div class="panel-title__right"></div>
      </div> -->
      <!-- content -->
      <div class="panel-content" :key="'content'+index" @click="itemClick(item)">
        <div class="panel-content__dec">
          <div class="panel-content__item">
            <div class="panel-content__item-label">许可文件名称</div>
            <div class="panel-content__item-value">{{item.LicensDocName||'-'}}</div>
            <div class="panel-content__item-right"></div>
          </div>
          <div class="panel-content__item">
            <div class="panel-content__item-label">有效期自</div>
            <div class="panel-content__item-value">{{item.ValidityFrom||'-'}}</div>
            <div class="panel-content__item-right"></div>
          </div>
          <div class="panel-content__item">
            <div class="panel-content__item-label">有效期至</div>
            <div class="panel-content__item-value">{{item.ValidityTo||'-'}}</div>
          </div>
        </div>
        <div class="panel-content__arrow">
          <i class="iconfont icon-more"></i>
        </div>
      </div>
    </template>
  </div>

</template>

<script>
export default {
  data() {
    return {
      items: []
    };
  },
  onReady() {
    this.getInfos();
  },
  onUnload() {
    this.items = [];
  },
  methods: {
    itemClick(item) {
      this.$router.push({
        path: './gongshang-detail/main',
        query: { item: JSON.stringify(item) }
      });
    },
    changeCount(count) {
      const item = { type: 'gongshang', count };
      this.$emit('countChange', item);
    },
    // async getInfos() {
    //   // 获取详情
    //   const company = this.$store.getters.companyInfo;
    //   const dt = company.Company;
    //   const Licens = dt.Licens;
    //   this.items = Licens;
    //   if (Licens.length) {
    //     this.changeCount(Licens.length);
    //   }
    // },

    async getInfos() {
      // 获取详情
      const url = '/app/getEntHistoryALInfo_VIP';
      const params = {
        unique: this.$root.$mp.page.options.Unique,
        pageIndex: 1
      };
      const res = await this.$http.get(url, params);
      if (res.status != 200) {
        wx.showToast({
          title: res.message || '获取失败！',
          icon: 'none',
          mask: true
        });
        return;
      }
      const result = res.result;
      this.items = result.Result;
      this.changeCount(result.Paging.TotalRecords);
    }
  }
};
</script>

